import { createApp } from "vue";
import * as components from "@/components/low-code/pc-library/index"
import { LowCode } from "@/components/low-code/core"
// import parse from "../parse/index.vue"
import PageDesigner from "../designer/index.vue"
import 'element-plus/dist/index.css'

/****
 * 编辑器
 */
import "./ace/ace-builds";
import codeEditor from "../components/code-editor/index.vue"


type Params = { custom: { config: any, widget: any, setting: any }[] }
export default function ({ container, opts }: { container: any, opts?: Params }) {


    const app = createApp(PageDesigner)
    console.log('app',app)
    console.log('components',components)

    for (const [key, component] of Object.entries(components)) {
        app.component(key + 'Designer', component)
    }
    // app.component("lowCodeParse", parse)
    app.component("lowCodeEditor", codeEditor)

    /****
     * 注册自定义组件
     */
    // if (opts?.custom && opts?.custom.length > 0) {
    //     LowCode.custom = opts?.custom
    //     console.log(opts.custom)
    //     opts.custom.map(item => {
    //         app.component(item.config.type + 'WidgetDesigner', item.widget)
    //         app.component(item.config.type + 'SettingDesigner', item.setting)
    //     })
    // }

    app.mount(container)


}